<?php

namespace app\admin\validate;

use think\Validate;

class Address extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require|max:4',
        'phone' => 'require|max:11|/^1[3-8]{1}[0-9]{9}$/',
        'provinces' => 'require',
        'detailed' => 'require',
        'postcode' => 'require',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'name.require' => '请输入姓名',
        'name.max' => '姓名字数不能超出四个字！',
        'provinces.require' => '请填写省市区',
        'detailed.require' => '请填写详细地址',
        'postcode.require' => '请填写邮政编码',
        'phone.require' => '请填写手机号码',
        'phone.max' => '手机号不能超过11位！',
        'phone./^1[3-8]{1}[0-9]{9}$/' => '手机号格式错误!',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name','provinces','detailed','postcode','phone'],
        'edit' => ['name','provinces','detailed','postcode','phone'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name' => __('Name'),
            'provinces' => __('Provinces'),
            'Detailed' => __('Detailed'),
            'Postcode' => __('Pobile'),
            'Phone' => __('Phone'),
        ];
        parent::__construct($rules, $message, $field);
    }
}
